package com.innovate.nms.service.command;

import lombok.Getter;
import lombok.Setter;

public class Proxy extends Command {
	
	//public static final String requestPrefix = "@ping:";
	public static final String responseOK = "ping:success!";
	public static final String responseNO = "ping:failed!";
	
	
	public void setProxy(String proxy) {
		this.setRemote(proxy);
	}
	
	@Setter
	private String target;
	
	@Getter
	private boolean attachable;
	
	@Override
	protected void prepare() {
		attachable = false;
	}


	@Override
	protected String buildRequest() {
		return this.buildCommand("ping:" + target + "!");
	}


	@Override
	protected boolean checkResponse(String response) {
		
		if(response.endsWith(responseOK)) {
			attachable = true;
			return true;
		}
		
		if(response.endsWith(responseNO)) {
			attachable = false;
			return true;
		}
		
		return false;
	}

	
}
